package org.lewis.demo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.mybatis.common.core.RowsResponse;
import io.mybatis.service.AbstractService;
import org.lewis.demo.mapper.TDemoBookMapper;
import org.lewis.demo.model.TDemoBook;
import org.lewis.demo.service.TDemoBookService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TDemoBookServiceImpl extends AbstractService<TDemoBook, String, TDemoBookMapper>
        implements TDemoBookService {

    @Override
    public RowsResponse<TDemoBook> findByPage(Map<String, Object> param, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<TDemoBook> list = this.baseMapper.findList(param);
        PageInfo<TDemoBook> pageInfo = new PageInfo<>(list);
        return RowsResponse.ok(list, pageInfo.getTotal());
    }

}
